<?php
/*
	监听电商客购买事件
	检查是否购买了指定商品
*/
defined('BY_JYA') or exit('error');
$mid=$event['order']['mid'];
$orderid=$event['order']['id'];
$time=$event['order']['paytime'];
$goodsid=pdo_getcolumn('jy_weishop_order_goods',array('uniacid'=>$_SESSION['uniacid'],'orderid'=>$orderid),'goodsid');
//查询是否购买了这个商品
//查询会员购买指定商品的任务
$tasks=pdo_getall('jy_renwu_task_record',array('uniacid'=>$_SESSION['uniacid'],'mid'=>$mid,'tasktype'=>'order_goods','stoptime >'=>time(),'finishtime >'=>'0'));
if($tasks){
	//修改任务状态为完成
	foreach($tasks as $task){
		if($task['task_demand'] == $goodsid){
		pdo_update('jy_renwu_task_record',array('finishtime'=>$time),array('id'=>$task['id']));
		}
	}
}